package gov.ccswj.modules.bdbusiness.controller;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import gov.ccswj.modules.bdbusiness.entity.AWmEntity;
import gov.ccswj.modules.bdbusiness.service.AWmService;
import gov.ccswj.common.utils.PageUtils;
import gov.ccswj.common.utils.Query;
import gov.ccswj.common.utils.R;




/**
 * 
 * 
 * @author KY.Cheng
 * @email ********@gmail.com
 * @date 2017-11-29 17:17:15
 */
@RestController
@RequestMapping("/bdbusiness/awm")
public class AWmController {
	@Autowired
	private AWmService aWmService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("bdbusiness:awm:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<AWmEntity> aWmList = aWmService.queryList(query);
		int total = aWmService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(aWmList, total, query.getLimit(), query.getPage());
		
		return R.ok().put("page", pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{country}")
	@RequiresPermissions("bdbusiness:awm:info")
	public R info(@PathVariable("country") String country){
		AWmEntity aWm = aWmService.queryObject(country);
		
		return R.ok().put("aWm", aWm);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("bdbusiness:awm:save")
	public R save(@RequestBody AWmEntity aWm){
		aWmService.save(aWm);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("bdbusiness:awm:update")
	public R update(@RequestBody AWmEntity aWm){
		aWmService.update(aWm);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("bdbusiness:awm:delete")
	public R delete(@RequestBody String[] countrys){
		aWmService.deleteBatch(countrys);
		
		return R.ok();
	}
	
}
